//
//  YYStarScoreView.h
//  YYStarScorePorject
//
//  Created by 蓓蕾 on 2021/11/26.
//

#import <UIKit/UIKit.h>

NS_ASSUME_NONNULL_BEGIN



typedef NS_ENUM(NSInteger, YYStarRateViewStyle){
    
    YYStarRateViewStyleWholeStar = 0,//全星评分
    YYStarRateViewStyleHalfStar = 1, //可半星评分
    YYStarRateViewStyleIncompleteStar = 2,//不完整星评分
};

@class YYStarScoreView;

#pragma mark - 代理
@protocol YYStarRateViewDelegate <NSObject>

@optional
- (void)starRateView:(YYStarScoreView *)starRateView didSelecteStarAtStarRate:(CGFloat)starRate;

@end

typedef void(^YYStarRateDidSelectStarBlock)(YYStarScoreView *starRateView, CGFloat starRate);


@interface YYStarConfig : NSObject
/** 左侧标题 */
@property (nonatomic, strong) NSString *titleString;
/** 左侧标题富文本 */
@property (nonatomic, strong) NSAttributedString *titleAttributedString;
/** 左侧标题字体颜色 默认为黑色 */
@property (nonatomic, strong) UIColor *titleTextColor;
/** 左侧标题背景颜色 默认是透明的 */
@property (nonatomic, strong) UIColor *titleBgColor;
/** 左侧标题字体大小 默认15 */
@property (nonatomic, strong) UIFont *titleFont;
/** 左侧标题与星级间距 默认 0 */
@property (nonatomic, assign) CGFloat titleBetweenStarOfSpace;
/** 右侧标题 */
@property (nonatomic, strong) NSString *infoString;
/** 右侧标题富文本 */
@property (nonatomic, strong) NSAttributedString *infoAttributedString;
/** 右侧标题字体颜色 默认黑色 */
@property (nonatomic, strong) UIColor *infoTextColor;
/** 右侧标题背景颜色 默认透明 */
@property (nonatomic, strong) UIColor *infoBgColor;
/** 右侧标题字体大小 默认12 */
@property (nonatomic, strong) UIFont *infoFont;
/** 右侧标题与星级间距 默认 0 */
@property (nonatomic, assign) CGFloat infoBetweenStarOfSpace;

/** 星星评分样式 默认全星评分 */
@property (nonatomic, assign) YYStarRateViewStyle style;
/** 未选中星星图标 */
@property (nonatomic, strong) NSString *normalImage;
/** 已选中星星图标 */
@property (nonatomic, strong) NSString *selectImage;
/** 星星数量 默认是5 */
@property (nonatomic, assign) NSInteger numberOfStars;
/** 当前打分 默认是0.0 */
@property (nonatomic, assign) CGFloat currentScore;
/** 星星间隔 默认是0 */
@property (nonatomic, assign) CGFloat spacingBetweenStars;
/** 星星尺寸 默认 {24,24} */
@property (nonatomic, assign) CGSize starSize;
/** 星星尺寸 默认 24 */
@property (nonatomic, assign) CGFloat starSizeOfWidth;
/** 是否动画 默认YES */
@property (nonatomic, assign) BOOL isAnimation;
/** 是否滑动打分 默认YES 适用于不完整星星打分 */
@property (nonatomic, assign) BOOL allowSlideScore;
/** 是否点击打分 默认YES */
@property (nonatomic, assign) BOOL allowClickScore;

@end

@interface YYStarScoreView : UIView

@property (nonatomic,assign) CGFloat currentScore;
@property (nonatomic, weak) id <YYStarRateViewDelegate> delegate; //代理
@property (nonatomic, copy) YYStarRateDidSelectStarBlock didSelectStarBlock;//点击或滑动打分的回调

/** 星星评分样式 默认全星评分 */
@property (nonatomic, assign) YYStarRateViewStyle style;
/** 是否动画 默认YES */
@property (nonatomic, assign) BOOL isAnimation;
/** 是否滑动打分 默认NO 适用于不完整星星打分 */
@property (nonatomic, assign) BOOL allowSlideScore;
/** 是否点击打分 默认YES */
@property (nonatomic, assign) BOOL allowClickScore;


#pragma mark - 下面的属性需要先在config中进行配置，才能直接使用来更新相关配置

/** 左侧标题 */
@property (nonatomic, strong) NSString *titleString;
/** 左侧标题富文本 */
@property (nonatomic, strong) NSAttributedString *titleAttributedString;
/** 左侧标题字体颜色 默认为黑色 */
@property (nonatomic, strong) UIColor *titleTextColor;
/** 左侧标题背景颜色 默认是透明的 */
@property (nonatomic, strong) UIColor *titleBgColor;
/** 左侧标题字体大小 默认15 */
@property (nonatomic, strong) UIFont *titleFont;
/** 左侧标题与星级间距 默认 5 */
@property (nonatomic, assign) CGFloat titleBetweenStarOfSpace;
/** 右侧标题 */
@property (nonatomic, strong) NSString *infoString;
/** 右侧标题富文本 */
@property (nonatomic, strong) NSAttributedString *infoAttributedString;
/** 右侧标题字体颜色 默认黑色 */
@property (nonatomic, strong) UIColor *infoTextColor;
/** 右侧标题背景颜色 默认透明 */
@property (nonatomic, strong) UIColor *infoBgColor;
/** 右侧标题字体大小 默认12 */
@property (nonatomic, strong) UIFont *infoFont;
/** 右侧标题与星级间距 默认 5 */
@property (nonatomic, assign) CGFloat infoBetweenStarOfSpace;



-(id)initWithConfig:(YYStarConfig *)config;

-(id)initWithResultBlock:(YYStarRateDidSelectStarBlock)block;

-(id)initWithConfig:(YYStarConfig *)config withResultBlock:(YYStarRateDidSelectStarBlock)block;

-(id)initWithFrame:(CGRect)frame withConfig:(YYStarConfig *)config;
-(id)initWithFrame:(CGRect)frame withResultBlock:(YYStarRateDidSelectStarBlock)block;

-(id)initWithFrame:(CGRect)frame withConfig:(YYStarConfig *)config withResultBlock:(YYStarRateDidSelectStarBlock)block;

@end

NS_ASSUME_NONNULL_END
